package com.hc.serviceImpl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;

import com.hc.bean.RoleBean;
import com.hc.comm.CommData;
import com.hc.dao.RunSqlDao;
import com.hc.daoImpl.RunSqlDaoImpl;
import com.hc.service.SetDataService;

public class SetDataServiceImpl implements SetDataService{

	@Override
	public void setdownFileData(Map<String,String[]> map,RoleBean bean) {
	

		
		SimpleDateFormat formate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


		double speedAvr = Double.parseDouble(map.get("speedAvr")[0]);
		double speedMax = Double.parseDouble(map.get("speedMax")[0]);
		double speedMin = Double.parseDouble(map.get("speedMin")[0]);
	
		String sql = "insert into downFileTestData( userNumber,vlanId1,vlanId2,cmdTime ,intranetIp,externalIp," +
				"speedAvr,speedMax,speedMin,bSize,bSizeNumber) values " +
		"('"+bean.getNumber()+"','"+bean.getVlanId1()+"','"+bean.getVlanId2()+"','"+formate.format(new Date())
		+"','"+bean.getIntranetIp()+"','"+bean.getExternalIp()+"',"+speedAvr+","+speedMax+","+speedMin
		+",'"+bean.getOrder().getName()+"','"+bean.getOrder().getBroadbandSize()+"M')";
	
		RunSqlDao dao = new RunSqlDaoImpl();
		dao.runSqlUpdate(sql);
	
	}

	@Override
	public void setWebData(Map<String,String[]> map,RoleBean bean) {
		
		SimpleDateFormat formate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		double lostRate = Double.parseDouble( map.get("lostRate")[0]);
		double shake = Double.parseDouble(map.get("shake")[0]);
		double timeDelayAvr = Double.parseDouble(map.get("timeDelayAvr")[0]);
		double timeDelayMax = Double.parseDouble(map.get("timeDelayMax")[0]);
		double timeDelayMin = Double.parseDouble(map.get("timeDelayMin")[0]);
		int testCount = Integer.parseInt(map.get("testCount")[0]);
		String url = map.get("url")[0];
		
	
		String sql = "insert into webTestData( url,userNumber,vlanId1,vlanId2,cmdTime ,intranetIp,externalIp," +
				"timedelayAvr,timedelayMax,timedelayMin,lostRate,shake,testCount,bSize) values " +
		"('"+url+"','"+bean.getNumber()+"','"+bean.getVlanId1()+"','"+bean.getVlanId2()+"','"+formate.format(new Date())
		+"','"+bean.getIntranetIp()+"','"+bean.getExternalIp()+"',"+timeDelayAvr+","+timeDelayMax+","+timeDelayMin
		+","+lostRate+","+shake+","+testCount+",'"+bean.getOrder().getName()+"')";
	
		RunSqlDao dao = new RunSqlDaoImpl();
		dao.runSqlUpdate(sql);
	}

}
